import java.util.*;
import java.util.stream.*;

public class StudentOptional {
    public static void main(String[] args) {
        List<Optional<Student>> stu = Arrays.asList(
                Optional.of(new Student(1,"a", 21)),
                Optional.empty(),
                Optional.of(new Student(2,"b", 16)),
                Optional.of(new Student(3,"c", 14)),
                Optional.of(new Student(4,"d", 18)),
                Optional.empty(),
                Optional.of(new Student(5,"e", 20)));

        stu.stream()
                .forEach(System.out::println);
        System.out.println(" ---");
        stu.stream()
                .filter(Optional::isPresent)
                .map(Optional::get)
                .filter(t -> t.getAge() > 18)
                .map(Student::getName)
                .forEach(System.out::println);

    }
}

